package loveqq.niceexcel.converter;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.poi.ss.usermodel.CellType;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * Excel单元格值数据
 *
 * @author zhongjh@tsintergy.com
 * @date 2022-08-18
 */
@Getter
@Setter
@ToString(of = {"type", "data"})
public class CellData<T> {

    private CellType type;

    private T data;

    private String stringValue;

    private BigDecimal numberValue;

    private Boolean booleanValue;

    private String formulaValue;

    private Date dateValue;

    private LocalDateTime localDateTimeValue;


    public CellData() {
    }

    public CellData(T data, CellType type) {
        this.data = data;
        this.type = type;
    }

    public CellData(String data) {
        this((T) data, CellType.STRING);
        this.stringValue = data;
    }

    public CellData(BigDecimal data) {
        this((T) data, CellType.NUMERIC);
        this.numberValue = data;
    }

    public CellData(Boolean data) {
        this((T) data, CellType.BOOLEAN);
        this.booleanValue = data;

    }

    public CellData(Date data) {
        this((T) data, CellType.NUMERIC);
        this.dateValue = data;
    }

    public CellData(LocalDateTime data) {
        this((T) data, CellType.NUMERIC);
        this.localDateTimeValue = data;
    }

}
